package com.school.campus.domain;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.school.common.annotation.Excel;
import com.school.common.core.domain.BaseEntity;

/**
 * 单聊会话（存储一对一聊天关系）对象 conversations
 *
 * @author wwj
 * @date 2025-11-07
 */
public class Conversations extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 会话ID（主键）
     */
    private Long id;

    /**
     * 聊天双方之一的用户ID（关联sys_user.user_id）
     */
    @Excel(name = "聊天双方之一的用户ID", readConverterExp = "关=联sys_user.user_id")
    private Long user1Id;

    /**
     * 聊天双方之二的用户ID（关联sys_user.user_id）
     */
    @Excel(name = "聊天双方之二的用户ID", readConverterExp = "关=联sys_user.user_id")
    private Long user2Id;

    /**
     * 最新消息ID（关联messages.id）
     */
    @Excel(name = "最新消息ID", readConverterExp = "关=联messages.id")
    private Long latestMsgId;

    /**
     * 最新消息时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "最新消息时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date latestMsgTime;

    /**
     * user1的未读消息数
     */
    @Excel(name = "user1的未读消息数")
    private Long unreadCount1;

    /**
     * user2的未读消息数
     */
    @Excel(name = "user2的未读消息数")
    private Long unreadCount2;

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setUser1Id(Long user1Id) {
        this.user1Id = user1Id;
    }

    public Long getUser1Id() {
        return user1Id;
    }

    public void setUser2Id(Long user2Id) {
        this.user2Id = user2Id;
    }

    public Long getUser2Id() {
        return user2Id;
    }

    public void setLatestMsgId(Long latestMsgId) {
        this.latestMsgId = latestMsgId;
    }

    public Long getLatestMsgId() {
        return latestMsgId;
    }

    public void setLatestMsgTime(Date latestMsgTime) {
        this.latestMsgTime = latestMsgTime;
    }

    public Date getLatestMsgTime() {
        return latestMsgTime;
    }

    public void setUnreadCount1(Long unreadCount1) {
        this.unreadCount1 = unreadCount1;
    }

    public Long getUnreadCount1() {
        return unreadCount1;
    }

    public void setUnreadCount2(Long unreadCount2) {
        this.unreadCount2 = unreadCount2;
    }

    public Long getUnreadCount2() {
        return unreadCount2;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("user1Id", getUser1Id())
                .append("user2Id", getUser2Id())
                .append("latestMsgId", getLatestMsgId())
                .append("latestMsgTime", getLatestMsgTime())
                .append("unreadCount1", getUnreadCount1())
                .append("unreadCount2", getUnreadCount2())
                .append("createTime", getCreateTime())
                .toString();
    }
}
